package com.qidian.mespro.controller;

import com.github.pagehelper.PageInfo;
import com.qidian.mespro.service.ProcessStepService;
import com.qidianit.mes.pojo.Process;
import com.qidianit.mes.pojo.ProcessStep;
import com.qidianit.mes.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ author: 周晓轩
 * @ company 起点编程
 * @ time: 2025/9/18 - 10:17
 * @ Description:
 */
@RestController
@RequestMapping("/processStep")
public class ProcessStepController {
    @Autowired
    private ProcessStepService processStepService;

    @GetMapping("page")
    public Result<PageInfo<ProcessStep>> list(Long processId, @RequestParam(defaultValue = "1")int pageNum, @RequestParam(defaultValue = "10")int size){
        return processStepService.selectProcessStepList(processId,pageNum,size);
    };

    @GetMapping("/get/{id}")
    public Result<ProcessStep> getById(@PathVariable("id") Long id){
        return processStepService.selectByProcessStepId(id);
    }

    @PostMapping("/add")
    public Result<ProcessStep> save(@RequestBody ProcessStep processStep){
        return processStepService.addProcessStep(processStep);
    };

    @PutMapping("/update")
    public Result update(@RequestBody ProcessStep processStep){
        return processStepService.updateProcessStep(processStep);
    };

    @DeleteMapping("/delete/{id}")
    public Result deleteById(@PathVariable Long id){
        return processStepService.deleteProcessStepById(id);
    }

}
